
import React, { Component } from 'react';
import { Button, Checkbox, Form, Input ,message} from 'antd';
import axios from 'axios';
import '../../assets/styles/loginindex.css'
class Enroll extends Component {
  render() {
    const onFinish = (values) => {
      axios
        .get(
          `https://reactapi.iynn.cn/api/common/auth/addAdmin?username=${
            values.username
          }&password=${values.password}&mobile=${values.mobile - 0}`
        )
        .then((res) => {
          if (res.data.errNo === 0) {
            message.success("注册成功！", 3, () => {
              window.location.reload();
            });
          }
        });
    };

    const onFinishFailed = (errorInfo) => {
      message.error('请确认信息')
    };
    return (
      <div className="aksoxsj">
        <Form
        className='zhuce-1'
          name="basic"
          labelCol={{
            span: 8,
          }}
          wrapperCol={{
            span: 16,
          }}
          initialValues={{
            remember: true,
          }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            label="用户名"
            name="username"
            rules={[
              {
                required: true,
                message: "请输入用户名!",
              },
            ]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            label="密码"
            name="password"
            rules={[
              {
                required: true,
                message: "请输入密码!",
              },
            ]}
          >
            <Input.Password />
          </Form.Item>
          <Form.Item
            label="手机号"
            name="mobile"
            rules={[
              {
                required: true,
                message: "请输入手机号!",
              },
            ]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            name="remembe"
            rules={[
              {
                  required: true,
                  message: '请勾选阅读用户协议',
              },
          ]}
            valuePropName="checked"
            wrapperCol={{
              offset: 8,
              span: 16,
            }}
          >
            <Checkbox>
              同意【用户协议】再进行注册
            </Checkbox>
          </Form.Item>

          <Form.Item
            wrapperCol={{
              offset: 8,
              span: 16,
            }}
          >
            <Button type="primary" htmlType="submit" block>
              注册
            </Button>
          </Form.Item>
        </Form>
      </div>
    );
  }
}

export default Enroll;
